<?php
class omeanalysts_ome_delivery extends ectools_analysis_abstract implements ectools_analysis_interface{
    public $type_options = array(
        'display' => 'true',
    );
    public $logs_options = array(
        '1' => array(   
            'name' => '包裹数量',
            'flag' => array(),
            'memo' => '发出的包裹总数',
            'icon' => 'money.gif',
        ),
        '2' => array(
            'name' => '快递费用',
            'flag' => array(),
            'memo' => '产生的快递费用总计',
            'icon' => 'money_delete.gif',
        ),
    );

    public $graph_options = array(
        'hidden' => true,
    );

    public function get_type(){
        $lab = '物流公司';
        $typeObj = $this->app->model('ome_type');
        $data = $typeObj->get_dly_corp();
        $return = array(
            'lab' => $lab,
            'data' => $data,
        );
        return $return;
    }

    public function ext_detail(&$detail){
        $filter = $this->_params;

        $filter = array(
            'time_from' => $filter['time_from'],
            'time_to' => $filter['time_to'],
            'type_id' => $filter['type_id'],
        );

        $deliveryObj = $this->app->model('ome_delivery');
        $delivery = $deliveryObj->get_delivery($filter);

        $detail['包裹数量']['value'] = $delivery['num'];
        $detail['快递费用']['value'] = number_format($delivery['cost'],2,"."," ");
    }

    public function finder(){
        return array(
            'model' => 'omeanalysts_mdl_ome_delivery',
            'params' => array(
                'actions'=>array(
                    array(
                        'label'=>app::get('omeanalysts')->_('生成报表'),
                        'class'=>'export',
                        'icon'=>'add.gif',
                        'href'=>'index.php?app=omeanalysts&ctl=ome_analysis&act=delivery&action=export',
                        'target'=>'{width:400,height:170,title:\'生成报表\'}'),
                ),
                'title'=>app::get('omeanalysts')->_('快递费结算表'),
                'use_buildin_recycle'=>false,
                'use_buildin_selectrow'=>false,
                'use_buildin_filter'=>true,
            ),
        );
    }
}